<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Class: Spec::Story::Runner::StoryRunner</title>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href="../../../.././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Class</strong></td>
          <td class="class-name-in-header">Spec::Story::Runner::StoryRunner</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../../../../files/vendor/plugins/rspec/lib/spec/story/runner/story_runner_rb.html">
                vendor/plugins/rspec/lib/spec/story/runner/story_runner.rb
                </a>
        <br />
            </td>
        </tr>

        <tr class="top-aligned-row">
            <td><strong>Parent:</strong></td>
            <td>
                <a href="../../../Object.html">
                Object
               </a>
            </td>
        </tr>
        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">



   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M000086">Story</a>&nbsp;&nbsp;
      <a href="#M000088">add_listener</a>&nbsp;&nbsp;
      <a href="#M000085">new</a>&nbsp;&nbsp;
      <a href="#M000087">run_stories</a>&nbsp;&nbsp;
      <a href="#M000084">scenario_from_current_story</a>&nbsp;&nbsp;
      <a href="#M000089">scenario_from_current_story</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->

    <div id="section">





    <div id="attribute-list">
      <h3 class="section-bar">Attributes</h3>

      <div class="name-list">
        <table>
        <tr class="top-aligned-row context-row">
          <td class="context-item-name">current_story</td>
          <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
          <td class="context-item-desc"></td>
        </tr>
        <tr class="top-aligned-row context-row">
          <td class="context-item-name">current_story_runner</td>
          <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
          <td class="context-item-desc"></td>
        </tr>
        <tr class="top-aligned-row context-row">
          <td class="context-item-name">scenarios</td>
          <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
          <td class="context-item-desc"></td>
        </tr>
        <tr class="top-aligned-row context-row">
          <td class="context-item-name">stories</td>
          <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
          <td class="context-item-desc"></td>
        </tr>
        </table>
      </div>
    </div>
      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Class methods</h3>

      <div id="method-M000085" class="method-detail">
        <a name="M000085"></a>

        <div class="method-heading">
          <a href="#M000085" class="method-signature">
          <span class="method-name">new</span><span class="method-args">(scenario_runner, world_creator = World)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000085-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000085-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/rspec/lib/spec/story/runner/story_runner.rb, line 15</span>
15:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">scenario_runner</span>, <span class="ruby-identifier">world_creator</span> = <span class="ruby-constant">World</span>)
16:           <span class="ruby-constant">StoryRunner</span>.<span class="ruby-identifier">current_story_runner</span> = <span class="ruby-keyword kw">self</span>
17:           <span class="ruby-ivar">@scenario_runner</span> = <span class="ruby-identifier">scenario_runner</span>
18:           <span class="ruby-ivar">@world_creator</span> = <span class="ruby-identifier">world_creator</span>
19:           <span class="ruby-ivar">@stories</span> = []
20:           <span class="ruby-ivar">@scenarios_by_story</span> = {}
21:           <span class="ruby-ivar">@scenarios</span> = []
22:           <span class="ruby-ivar">@listeners</span> = []
23:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000084" class="method-detail">
        <a name="M000084"></a>

        <div class="method-heading">
          <a href="#M000084" class="method-signature">
          <span class="method-name">scenario_from_current_story</span><span class="method-args">(scenario_name)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000084-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000084-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/rspec/lib/spec/story/runner/story_runner.rb, line 8</span>
 8:           <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">scenario_from_current_story</span>(<span class="ruby-identifier">scenario_name</span>)
 9:             <span class="ruby-identifier">current_story_runner</span>.<span class="ruby-identifier">scenario_from_current_story</span>(<span class="ruby-identifier">scenario_name</span>)
10:           <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M000086" class="method-detail">
        <a name="M000086"></a>

        <div class="method-heading">
          <a href="#M000086" class="method-signature">
          <span class="method-name">Story</span><span class="method-args">(title, narrative, params = {}, &amp;body)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000086-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000086-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/rspec/lib/spec/story/runner/story_runner.rb, line 25</span>
25:         <span class="ruby-keyword kw">def</span> <span class="ruby-constant">Story</span>(<span class="ruby-identifier">title</span>, <span class="ruby-identifier">narrative</span>, <span class="ruby-identifier">params</span> = {}, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">body</span>)
26:           <span class="ruby-identifier">story</span> = <span class="ruby-constant">Story</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">title</span>, <span class="ruby-identifier">narrative</span>, <span class="ruby-identifier">params</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">body</span>)
27:           <span class="ruby-ivar">@stories</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">story</span>
28:           
29:           <span class="ruby-comment cmt"># collect scenarios</span>
30:           <span class="ruby-identifier">collector</span> = <span class="ruby-constant">ScenarioCollector</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">story</span>)
31:           <span class="ruby-identifier">story</span>.<span class="ruby-identifier">run_in</span>(<span class="ruby-identifier">collector</span>)
32:           <span class="ruby-ivar">@scenarios</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">collector</span>.<span class="ruby-identifier">scenarios</span>
33:           <span class="ruby-ivar">@scenarios_by_story</span>[<span class="ruby-identifier">story</span>.<span class="ruby-identifier">title</span>] = <span class="ruby-identifier">collector</span>.<span class="ruby-identifier">scenarios</span>
34:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000088" class="method-detail">
        <a name="M000088"></a>

        <div class="method-heading">
          <a href="#M000088" class="method-signature">
          <span class="method-name">add_listener</span><span class="method-args">(listener)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000088-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000088-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/rspec/lib/spec/story/runner/story_runner.rb, line 60</span>
60:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">add_listener</span>(<span class="ruby-identifier">listener</span>)
61:           <span class="ruby-ivar">@listeners</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">listener</span>
62:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000087" class="method-detail">
        <a name="M000087"></a>

        <div class="method-heading">
          <a href="#M000087" class="method-signature">
          <span class="method-name">run_stories</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000087-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000087-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/rspec/lib/spec/story/runner/story_runner.rb, line 36</span>
36:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">run_stories</span>
37:           <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@stories</span>.<span class="ruby-identifier">empty?</span>
38:           <span class="ruby-ivar">@listeners</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">l</span><span class="ruby-operator">|</span> <span class="ruby-identifier">l</span>.<span class="ruby-identifier">run_started</span>(<span class="ruby-identifier">scenarios</span>.<span class="ruby-identifier">size</span>) }
39:           <span class="ruby-identifier">success</span> = <span class="ruby-keyword kw">true</span>
40:           <span class="ruby-ivar">@stories</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">story</span><span class="ruby-operator">|</span>
41:             <span class="ruby-identifier">story</span>.<span class="ruby-identifier">assign_steps_to</span>(<span class="ruby-constant">World</span>)
42:             <span class="ruby-ivar">@current_story</span> = <span class="ruby-identifier">story</span>
43:             <span class="ruby-ivar">@listeners</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">l</span><span class="ruby-operator">|</span> <span class="ruby-identifier">l</span>.<span class="ruby-identifier">story_started</span>(<span class="ruby-identifier">story</span>.<span class="ruby-identifier">title</span>, <span class="ruby-identifier">story</span>.<span class="ruby-identifier">narrative</span>) }
44:             <span class="ruby-identifier">scenarios</span> = <span class="ruby-ivar">@scenarios_by_story</span>[<span class="ruby-identifier">story</span>.<span class="ruby-identifier">title</span>]
45:             <span class="ruby-identifier">scenarios</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">scenario</span><span class="ruby-operator">|</span>
46:               <span class="ruby-identifier">type</span> = <span class="ruby-identifier">story</span>[<span class="ruby-identifier">:type</span>] <span class="ruby-operator">||</span> <span class="ruby-constant">Object</span>
47:               <span class="ruby-identifier">args</span> = <span class="ruby-identifier">story</span>[<span class="ruby-identifier">:args</span>] <span class="ruby-operator">||</span> []
48:               <span class="ruby-identifier">world</span> = <span class="ruby-ivar">@world_creator</span>.<span class="ruby-identifier">create</span>(<span class="ruby-identifier">type</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
49:               <span class="ruby-identifier">success</span> = <span class="ruby-identifier">success</span> <span class="ruby-operator">&amp;</span> <span class="ruby-ivar">@scenario_runner</span>.<span class="ruby-identifier">run</span>(<span class="ruby-identifier">scenario</span>, <span class="ruby-identifier">world</span>)
50:             <span class="ruby-keyword kw">end</span>
51:             <span class="ruby-ivar">@listeners</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">l</span><span class="ruby-operator">|</span> <span class="ruby-identifier">l</span>.<span class="ruby-identifier">story_ended</span>(<span class="ruby-identifier">story</span>.<span class="ruby-identifier">title</span>, <span class="ruby-identifier">story</span>.<span class="ruby-identifier">narrative</span>) }
52:             <span class="ruby-constant">World</span>.<span class="ruby-identifier">step_mother</span>.<span class="ruby-identifier">clear</span>
53:           <span class="ruby-keyword kw">end</span>
54:           <span class="ruby-identifier">unique_steps</span> = (<span class="ruby-constant">World</span>.<span class="ruby-identifier">step_names</span>.<span class="ruby-identifier">collect</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">n</span><span class="ruby-operator">|</span> <span class="ruby-constant">Regexp</span> <span class="ruby-operator">===</span> <span class="ruby-identifier">n</span> <span class="ruby-value">? </span><span class="ruby-identifier">n</span>.<span class="ruby-identifier">source</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">n</span>.<span class="ruby-identifier">to_s</span>}).<span class="ruby-identifier">uniq</span>.<span class="ruby-identifier">sort</span>
55:           <span class="ruby-ivar">@listeners</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">l</span><span class="ruby-operator">|</span> <span class="ruby-identifier">l</span>.<span class="ruby-identifier">collected_steps</span>(<span class="ruby-identifier">unique_steps</span>) }
56:           <span class="ruby-ivar">@listeners</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">l</span><span class="ruby-operator">|</span> <span class="ruby-identifier">l</span>.<span class="ruby-identifier">run_ended</span> }
57:           <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">success</span>
58:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000089" class="method-detail">
        <a name="M000089"></a>

        <div class="method-heading">
          <a href="#M000089" class="method-signature">
          <span class="method-name">scenario_from_current_story</span><span class="method-args">(scenario_name)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000089-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000089-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/rspec/lib/spec/story/runner/story_runner.rb, line 64</span>
64:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">scenario_from_current_story</span>(<span class="ruby-identifier">scenario_name</span>)
65:           <span class="ruby-ivar">@scenarios_by_story</span>[<span class="ruby-ivar">@current_story</span>.<span class="ruby-identifier">title</span>].<span class="ruby-identifier">find</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">s</span><span class="ruby-operator">|</span> <span class="ruby-identifier">s</span>.<span class="ruby-identifier">name</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">scenario_name</span> }
66:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>